#include <string>
#include <iostream>
#include <sstream>
#include "hashtbl.h"
#include "EncodedStructs.h"

using std::cout;
using std::endl;


/*void something(vector<Decoded> &v)
{
	cout<<"here: "<<v[0].opcode<<endl;
}*/
int main()
{
	
/*	vector<Decoded> DeInstructions; 

	INSTU u;

	Decoded I;
	I.opcode="add";
	I.reg1="$21";

	DeInstructions.push_back(I);

	if(I.opcode=="add") 
	{
		u.D.opcode=23;
		u.D.pad=17999073;
		EnInsts.push_back(u.instruction);
		cout<<EnInsts[0]<<endl;
	}

	else cout<<I.opcode<<endl;

	EnInsts.push_back(2);
	cout<<"here:"<<EnInsts[1]<<endl;
	something(DeInstructions);*/
	
	HashTbl *tbl;

	class numbers
	{
		public:
			int op;
			int funct;
	};

	numbers n, a, *p;
	n.op=0;
	n.funct=32;


	if(!(tbl=new HashTbl(16, NULL))) {
		fprintf(stderr, "ERROR: hashtbl_create() failed\n");
		exit(EXIT_FAILURE);
	}

	
	tbl->insert("mfc0", &n);


	a.op=2;
	a.funct=30;

	tbl->insert("add", &a);

	p=(numbers *)tbl->get("mfc0");
	if(!p) printf("No match\n");
	else printf("Mfc0: %d, %d\n", p->funct, p->op);


	p=(numbers *)tbl->get("add");
	if(!p) printf("No match\n");
	else printf("Add: %d, %d\n", p->funct, p->op);
	//if(p->funct==3) printf("It equals\n");
	a.op=50;
	a.funct=50;

	tbl->insert("more", &a);
	p=(numbers *)tbl->get("more");
	printf("more: %d, %d\n", p->funct, p->op);

	a.op=42;
	a.funct=22;

	tbl->insert("mor", &a);
	p=(numbers *)tbl->get("mor");
	printf("mor: %d, %d\n", p->funct, p->op);

	p=(numbers *)tbl->get("more");
	printf("more: %d, %d\n", p->funct, p->op);

	delete(tbl);
	return 0;
}




